package com.wdz.category.entity;

import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.wdz.annotations.SearchCondition;
import com.wdz.annotations.SearchSqlCondition;
import com.wdz.article.entity.Article;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 分类表
 * </p>
 *
 * @author 吴传逞
 * @since 2020-12-14
 */
@TableName("category")
public class Category extends Model<Category> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id",type = IdType.UUID)
    private String id;
    /**
     * 分类名
     */
    @SearchCondition()
    @NotNull
    private String name;
    /**
     * 父分类id
     */
    @SearchCondition(value="parent_category_id",type = SearchSqlCondition.EQ)
    @TableField("parent_category_id")
    private String parentCategoryId;
    /**
     * 上级分类名
     */
    @TableField("parent_category_name")
    private String parentCategoryName;
    /**
     * 所属主分类id
     */
    @TableField("main_category_id")
    @SearchCondition(value="main_category_id",type = SearchSqlCondition.EQ)
    private String mainCategoryId;

    public String getMainCategoryId() {
        return mainCategoryId;
    }

    public void setMainCategoryId(String mainCategoryId) {
        this.mainCategoryId = mainCategoryId;
    }

    public String getMainCategoryName() {
        return mainCategoryName;
    }

    public void setMainCategoryName(String mainCategoryName) {
        this.mainCategoryName = mainCategoryName;
    }

    /**
     * 所属主分类名
     */
    @TableField("main_category_name")
    private String mainCategoryName;
    /**
     * 分类等级：0-顶级分类，1-二级分类，2-三级分类
     */
    @NotNull
    @SearchCondition(type = SearchSqlCondition.EQ)
    private Integer level;
    /**
     * 分类类型：0-作品分类，1-文章分类
     */
    private Integer type;
    /**
     * 创建时间
     */
    @TableField(value = "create_date", fill = FieldFill.INSERT)
    private String createDate;

    @SearchCondition(value="create_date",type = SearchSqlCondition.LE)
    @TableField(exist = false)
    private String createDateLe;

    @SearchCondition(value="create_date",type = SearchSqlCondition.GE)
    @TableField(exist = false)
    private String createDateGe;

    public String getCreateDateLe() {
        return createDateLe;
    }

    public void setCreateDateLe(String createDateLe) {
        this.createDateLe = createDateLe;
    }

    public String getCreateDateGe() {
        return createDateGe;
    }

    public void setCreateDateGe(String createDateGe) {
        this.createDateGe = createDateGe;
    }

    /**
     * 修改时间
     */
    @TableField(value = "update_date", fill = FieldFill.INSERT_UPDATE)
    private String updateDate;

    /**
     * 分类代表图片集
     */
    @TableField(exist = false)
    private List<String> images;

    /**
     * 分类下的文章数量
     */
    @TableField(exist = false)
    private Integer articleVolume;

    /**
     * 分类下面的文章集合
     */
    @TableField(exist = false)
    private List<Article> articles;

    public List<Article> getArticles() {
        return articles;
    }

    public void setArticles(List<Article> articles) {
        this.articles = articles;
    }

    public Integer getArticleVolume() {
        return articleVolume;
    }

    public void setArticleVolume(Integer articleVolume) {
        this.articleVolume = articleVolume;
    }

    public List<String> getImages() {
        return images;
    }

    public void setImages(List<String> images) {
        this.images = images;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParentCategoryId() {
        return parentCategoryId;
    }

    public void setParentCategoryId(String parentCategoryId) {
        this.parentCategoryId = parentCategoryId;
    }

    public String getParentCategoryName() {
        return parentCategoryName;
    }

    public void setParentCategoryName(String parentCategoryName) {
        this.parentCategoryName = parentCategoryName;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public String getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "Category{" +
        ", id=" + id +
        ", name=" + name +
        ", parentCategoryId=" + parentCategoryId +
        ", parentCategoryName=" + parentCategoryName +
        ", level=" + level +
        ", type=" + type +
        ", createDate=" + createDate +
        ", updateDate=" + updateDate +
        "}";
    }
}
